package com.accp.vehiclecare.action.xzhaction;

import com.accp.vehiclecare.biz.xzhbiz.ArmemberBiz;
import com.accp.vehiclecare.biz.xzhbiz.ArtisansBiz;
import com.accp.vehiclecare.biz.xzhbiz.ArvehicleBiz;
import com.accp.vehiclecare.pojo.*;
import com.accp.vehiclecare.vo.hzvo.Vehicletype;
import com.accp.vehiclecare.vo.xzhvo.ArmemberVO;
import com.accp.vehiclecare.vo.xzhvo.GroupclassifyVO;
import com.accp.vehiclecare.vo.xzhvo.arvehicleVO;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.*;
@Api(tags="班组信息接口模块")
@RestController
@RequestMapping("/api/ArtisansAction")
public class ArtisansAction {
    @Autowired
    private ArtisansBiz artisansBiz;
    @Autowired
    private ArmemberBiz armemberBiz;
    @Autowired
    private ArvehicleBiz arvehicleBiz;

    /**
     * 查询班组类别 & 班组信息
     * @return
     */
    @ApiOperation(value="查询班组类别以及班组信息", notes = "查询班组类别以及班组信息", httpMethod = "GET")
    @GetMapping("/queryArtisans")
    public List<GroupclassifyVO> queryArtisans(){
        return artisansBiz.queryArtisans();
    }

    /**
     * 查询班组成员
     * @param artisansid
     * @return
     */
    @GetMapping("/queryArmember/{PageNum}/{PageSize}")
    public PageInfo<ArmemberVO> queryArmember(@PathVariable Integer PageNum,@PathVariable Integer PageSize,Integer artisansid,String armembername){
        return artisansBiz.queryArmember(artisansid,PageNum,PageSize,armembername);
    }

    /**
     * 查询班组
     * @return
     */
    @GetMapping("/queryShift")
    public List<Artisans> queryShift(){
        return artisansBiz.queryShift();
    }

    /**
     * 新增班组成员
     * @param armember
     * @return
     */
    @PostMapping("/addArmember")
    public Map<Object,String>addArmember(@RequestBody Armember armember){
        Map<Object,String> map = new HashMap<Object,String>();
        boolean bol=armemberBiz.addArmember(armember);
        if(bol){
            map.put("code","200");
            map.put("msg","ok");
        }else {
            map.put("code","300");
            map.put("msg","no");
        }
        return map;
    }

    /**
     * 修改班组成员
     * @param armember
     * @return
     */
    @PutMapping("amendArmember")
    public Map<Object,String>amendArmember(@RequestBody Armember armember){
        Map<Object,String> map = new HashMap<Object,String>();
        boolean bol=armemberBiz.amendArmember(armember);
        if(bol){
            map.put("code","200");
            map.put("msg","ok");
        }else {
            map.put("code","300");
            map.put("msg","no");
        }
        return map;
    }

    /**
     * 删除员工
     * @param id
     * @return
     */
    @DeleteMapping("/removeArmember/{id}")
    public Map<Object,String>removeArmember(@PathVariable Integer id){
        Map<Object,String> map = new HashMap<Object,String>();
        boolean bol=armemberBiz.removeArmember(id);
        if(bol){
            map.put("code","200");
            map.put("msg","ok");
        }else {
            map.put("code","300");
            map.put("msg","no");
        }
        return map;
    }

    /**
     * 查询班组类别
     * @return
     */
    @GetMapping("/queryGroupClassIfy")
    public List<Groupclassify>queryGroupClassIfy(){
        return artisansBiz.queryGroupClassIfy();
    }

    /**
     * 新增班组
     * @param artisans
     * @return
     */
    @PostMapping("/addArtisans")
    public Map<Object,String>addArtisans(@RequestBody Artisans artisans){
        Map<Object,String> map = new HashMap<Object,String >();
        boolean bol= artisansBiz.addArtisans(artisans);
        if(bol){
            map.put("code","200");
            map.put("msg","ok");
        }else{
            map.put("code","200");
            map.put("msg","on");
        }
        return map;
    }

    /**
     * 修改班组
     * @param artisans
     * @return
     */
    @PutMapping("/ModifyArtisans")
    public Map<Object,String>ModifyArtisans(@RequestBody Artisans artisans){
        Map<Object,String> map = new HashMap<Object,String >();
        boolean bol= artisansBiz.ModifyArtisans(artisans);
        if(bol){
            map.put("code","200");
            map.put("msg","ok");
        }else{
            map.put("code","200");
            map.put("msg","on");
        }
        return map;
    }

    /**
     * 删除班组
     * @param artisansid
     * @return
     */
    @DeleteMapping("/deleteArtisans/{artisansid}")
    public Map<Object,String>deleteArtisans(@PathVariable Integer artisansid){
        Map<Object,String> map = new HashMap<Object,String >();
        boolean bol= artisansBiz.deleteArtisans(artisansid);
        if(bol){
            map.put("code","200");
            map.put("msg","ok");
        }else{
            map.put("code","200");
            map.put("msg","on");
        }
        return map;
    }

    /**
     * 查询车辆型号
     * @return
     */
    @GetMapping("/queryVehicleType")
    public List<Vehicletype> queryVehicleType(){
        return artisansBiz.queryVehicleType();
    }

    /**
     * 查询外勤车辆
     * @return
     */
    @GetMapping("/queryArvehicle")
    public List<arvehicleVO> queryArvehicle(){
        return artisansBiz.queryArvehicle();
    }

    /**
     * 新增外勤车辆
     * @param arvehicle
     * @return
     */
    @PostMapping("/addArvehicle")
    public Map<Object,String> addArvehicle(@RequestBody Arvehicle arvehicle){
        Map<Object,String> map = new HashMap<Object,String>();
        boolean bol = arvehicleBiz.addArvehicle(arvehicle);
        if(bol){
            map.put("code","200");
            map.put("msg","ok");
        }else{
            map.put("code","300");
            map.put("msg","on");
        }
        return map;
    }

    /**
     * 删除外勤车辆
     * @param id
     * @return
     */
    @DeleteMapping("/removeArvehicle/{id}")
    public Map<Object,String> removeArvehicle(@PathVariable Integer id){
        Map<Object,String> map = new HashMap<Object,String>();
        boolean bol = arvehicleBiz.removeArvehicle(id);
        if(bol){
            map.put("code","200");
            map.put("msg","ok");
        }else{
            map.put("code","300");
            map.put("msg","on");
        }
        return map;
    }

    /**
     * 修改外勤车辆
     * @param arvehicle
     * @return
     */
    @PutMapping("/amendArvehicle")
    public Map<Object,String> amendArvehicle(@RequestBody Arvehicle arvehicle){
        Map<Object,String> map = new HashMap<Object,String>();
        boolean bol = arvehicleBiz.amendArvehicle(arvehicle);
        if(bol){
            map.put("code","200");
            map.put("msg","ok");
        }else{
            map.put("code","300");
            map.put("msg","on");
        }
        return map;
    }






}
